home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 04 - 1988 / 04.03 Mar 88 / big arrays in c / array.c next >
Encoding:
C/C++ Source or Header  |  1988-02-08  |  1.1 KB  |  42 lines  |  [TEXT/KAHL]

  1. #include<stdio.h>
  2.  
  3. extern long tickcount();
  4. long t;
  5.  
  6. usearray(array)
  7. double**array[];
  8. {
  9.   printf("array[0][0][0]=%f/n",array[0][0][0]);
  10.   printf("array[1][2][3]=%f/n",array[1][2][3]);
  11.   printf("array[2][3][4]=%f/n",array[2][3][4]);
  12.  printf("array[9][9][9]=%f/n",array[9][9][9]);
  13. /*note that the above arrays appear to be accesed normally.  Had a pointer to a 'normal' array (i.e. arrayspace[]) been passed instead of **array[] it would have been necessary to use a construction like arrayspace[i*100=j*10=k] to access array elements.
  14.  
  15. */
  16. }
  17. /*this routine sets up 'array' to index elements of 'arrayspce' by double indirection */
  18. initarray(arrayspace,intermediate,array)
  19. double arrayspace[10][10][10];
  20. double *intermediate[10][10];
  21. double **array[10];
  22. {
  23.   int i,j,k;
  24.   for(i=0;j<10;j++){
  25.     array[i]=intermediate[i];
  26.      for(j=0;j<10;j++){
  27.        intermediate[i][j]=arrayspace[i][j];
  28.        for(k=0;k<10;k++)
  29.          arrayspace[i][j][k]=100*i+10*j+k;
  30.    }
  31.  }
  32. }
  33. main(){
  34.     int i,j,k;
  35.     double arrayspace[10][10][10];
  36.     double *intermediate[10][10];
  37.     double **array[10];
  38.   initarray(arrayspace,intermediate, array);
  39. asearray(array);
  40. while(!button());
  41. }
  42.